// 纵向扫描
class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        if(!strs.size()) return "";
        int n = strs.size(), length = strs[0].size();
        for(int i = 0; i < length; ++i)
        {
            char buf = strs[0][i];
            for(int j = 1; j < n; ++j)
            {
                if(i == strs[j].size() || strs[j][i] != buf)
                {
                    return strs[0].substr(0, i);
                }
            }
        }
        return strs[0];
    }
};